package com.woniuxy.dao;

import com.woniuxy.entity.RbacManager;
import org.apache.ibatis.annotations.Select;

import java.util.Set;

public interface ManagerLoginDao {
    @Select("select id,account,roles from rbac_manager where account=#{account} and password=#{password} and status='y'")
    RbacManager login(RbacManager rbacManager);
    @Select("select password from rbac_manager where account=#{account}")
    String findPassword(String username);
    @Select("select name from rbac_role where FIND_IN_SET(id,(select roles from rbac_manager where account = #{username})) ")
    Set<String> findAllRoles(String username);
    @Select("select code from rbac_perm pm LEFT JOIN rbac_role_perm rp on pm.id=rp.perm_id " +
            " where rp.role_id IN (select r.id from rbac_role r" +
            " where FIND_IN_SET(r.id,(select m.roles from rbac_manager m where m.account = #{username})))")
    Set<String> findAllPerms(String username);
}
